<template>
    <div class="user-profile-container">
        <!-- 基本信息部分 -->
        <div class="profile-section">
            <h2 class="section-title">您的基本信息</h2>
            <div v-if="userInfo" class="user-info-content">
                <div class="info-item">
                    <span class="info-label">账号名：</span>
                    <span class="info-value">{{ userInfo.name }}</span>
                </div>
                <div class="info-item">
                    <span class="info-label">绑定手机：</span>
                    <span class="info-value">{{ userInfo.phone }}</span>
                    <a href="#" class="modify-link">修改手机号</a>
                </div>
            </div>
            <div v-else class="loading-placeholder">
                <div class="info-item">
                    <span class="info-label">账号名：</span>
                    <span class="info-value">加载中...</span>
                </div>
                <div class="info-item">
                    <span class="info-label">绑定手机：</span>
                    <span class="info-value">加载中...</span>
                </div>
            </div>
        </div>

        <!-- 登录设置部分 -->
        <div class="profile-section">
            <h2 class="section-title">您的登录设置</h2>
            <div class="setting-item">
                <label class="checkbox-container">
                    <input type="checkbox" checked>
                    <span class="checkmark"></span>
                    <span class="setting-label">保持登录状态</span>
                </label>
                <span class="setting-description">开启后7天内无需重复登录</span>
            </div>
        </div>

        <!-- 安全服务部分 -->
        <div class="profile-section">
            <h2 class="section-title">您的安全服务</h2>
            
            <div class="security-level">
                <span class="security-label">安全等级：</span>
                <div class="level-indicator">
                    <div class="level-bar high"></div>
                </div>
                <span class="level-text">高</span>
            </div>
            
            <div class="security-service">
                <div class="service-icon verified">
                    <i class="icon identity"></i>
                    <span class="status">已认证</span>
                </div>
                <div class="service-info">
                    <h3 class="service-title">身份认证</h3>
                    <p class="service-description">
                        用于提升账号的安全性和信任级别。认证后的有卖家记录的账号不能修改认证信息。
                    </p>
                </div>
            </div>
            
            <div class="security-service">
                <div class="service-icon not-set">
                    <i class="icon question"></i>
                    <span class="status">未设置</span>
                </div>
                <div class="service-info">
                    <h3 class="service-title">密保问题</h3>
                    <p class="service-description">
                        是您找回登录密码的方式之一。建议您设置一个容易记住，且最不容易被他人获取的问题及答案，更有效保障您的密码安全。
                    </p>
                    <a href="#" class="setup-link">立即设置</a>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { useStore } from 'vuex'
import { computed } from 'vue'

const store = useStore()
const userInfo = computed(() => store.state.user.userInfo)
</script>

<style scoped>
.user-profile-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: #333;
}

.profile-section {
    padding: 20px 0;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 20px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #222;
}

.user-info-content, .loading-placeholder {
    padding-left: 20px;
}

.info-item {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.info-label {
    width: 100px;
    font-weight: 500;
    color: #666;
}

.info-value {
    flex: 1;
    color: #333;
}

.modify-link {
    margin-left: 20px;
    color: #1890ff;
    text-decoration: none;
    font-size: 14px;
}

.modify-link:hover {
    text-decoration: underline;
}

.setting-item {
    display: flex;
    align-items: center;
    padding-left: 20px;
    margin-bottom: 15px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding-left: 30px;
    margin-right: 15px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: #1890ff;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: #1890ff;
    border-color: #1890ff;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.setting-label {
    font-weight: 500;
    margin-left: 8px;
}

.setting-description {
    color: #999;
    font-size: 13px;
}

.security-level {
    display: flex;
    align-items: center;
    padding-left: 20px;
    margin-bottom: 20px;
}

.security-label {
    width: 100px;
    font-weight: 500;
    color: #666;
}

.level-indicator {
    flex: 1;
    height: 8px;
    background-color: #f0f0f0;
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.level-bar {
    height: 100%;
    border-radius: 4px;
}

.level-bar.high {
    width: 90%;
    background-color: #52c41a;
}

.level-text {
    color: #52c41a;
    font-weight: 500;
}

.security-service {
    display: flex;
    padding: 15px 20px;
    background-color: #fafafa;
    border-radius: 4px;
    margin-bottom: 15px;
}

.service-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    flex-shrink: 0;
}

.service-icon.verified {
    background-color: #f6ffed;
    border: 1px solid #b7eb8f;
}

.service-icon.not-set {
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
}

.icon {
    width: 24px;
    height: 24px;
    display: block;
    margin-bottom: 5px;
}

.icon.identity {
    background-color: #52c41a;
    border-radius: 50%;
}

.icon.question {
    background-color: #ff4d4f;
    border-radius: 50%;
}

.status {
    font-size: 12px;
    color: #666;
}

.service-info {
    flex: 1;
}

.service-title {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.service-description {
    font-size: 14px;
    color: #666;
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.setup-link {
    color: #1890ff;
    text-decoration: none;
    font-size: 14px;
}

.setup-link:hover {
    text-decoration: underline;
}
</style>